package com.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/test")
public class ChatGPT {

    @Autowired
    private RedisTemplate redisTemplate;

    @ApiIdempotent
    @GetMapping("/t1")
    public Object test(){
        return "ok";
    }


    @GetMapping("/t2")
    public String createToken() {
        String token = UUID.randomUUID().toString();
        redisTemplate.opsForValue().set(token, token, 30, TimeUnit.MINUTES);
        return token;
    }
    

}
